import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';
import p001 from './p001';
import p002 from './p002';
export default async function a001(fd: IFeidaoAiBrowserComponent, c: { attr_no: string, attr_name: string }) {
	// todo打开弹窗
	const ssr = fd.data.node.querySelector<HTMLDivElement>('[data-zzs="ssr"]');
	set_node_cls(ssr, 'display-n', false);
	const attr_no = c.attr_no;
	set(fd, 'a', attr_no);
	const res = await nodejs<{ rs: Array<{}>, c: number }>('device-management/zj-000004/s001', {
		filter: {
			attr_no,
			page_no: 1
		}
	});
	for (let i = 0; i < res.rs.length; i++) {
		const w = res.rs[i] as { _id: string, productid: string, priority: string, attr_no: string, optional_value_no: string, optional_value: string, attr_name: string };
		w.attr_name = c.attr_name;
	}
	const page_no = 1;
	render(fd, res.rs, p001, 'p001', 'inner');
	render(fd, { pageno: page_no, total: res.c }, p002, 'p002', 'inner');
}
